<template>
    <div>
<!-- 面包屑导航 -->
        <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/index' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>密码修改</el-breadcrumb-item>
        </el-breadcrumb>
    <div class="aa">

    <el-form label-width="80px" :model="Form" style="margin-top: 60px;
        padding-top: 10px;" >
        <el-form-item label="账号" >
          <el-input style="width:300px;" size="small" disabled v-model="Form.username" auto-complete="off" placeholder="账号"></el-input>
        </el-form-item>
        <el-form-item label="原密码" >
          <el-input style="width:300px;" size="small" clearable v-model="Form.password" auto-complete="off" placeholder="请输入原密码"></el-input>
        </el-form-item>
         <el-form-item label="新密码" >
          <el-input style="width:300px;" size="small" clearable v-model="Form.newPassword" auto-complete="off" placeholder="请输入新密码"></el-input>
        </el-form-item>

    </el-form>
        <el-button style="margin-left:30px;margin-bottom:10px" size="small"   type="primary" :loading="loading" class="title" @click="submitForm()">保存</el-button>
    </div>

    </div>

</template>
<script>
export default {
    data() {
        return {
            Form:{
                password:"",
                newPassword:'',
                username:""
            },
            loading:false,
            user:{}
        }
    },
    created(){
       this.Form.username = JSON.parse(window.sessionStorage.getItem('user')).username
    },
    methods:{
        submitForm(){ //保存密码
            this.loading =true;
            if(this.Form.username.trim() == "" || this.Form.newPassword.trim() == ""){
                this.$message.error("数据不可以为空！")
                 this.loading = false
                return;
            }
            if(this.Form.password != this.Form.newPassword){
                this.$message.error("两次密码不一致")
                return;
            }
            this.$api.post("/user/admin/updateAdmin",this.Form,Response=>{
                                  if(Response.data.code == 200){
                                      this.$message.success("修改成功！")
                                      this.Form.password = ""
                                      this.Form.newPassword=""
                                  }else{
                                      this.$message.error(Response.data.data)
                                  }
                            })
            setTimeout(()=>{
                this.loading = false
            },1500)
        }
    }
}
</script>
<style  scoped>
.aa{
    width: 500px;
    margin-top: 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)
}
</style>